<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script type="text/javascript" src="js/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="js/jquery.idTabs.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/redmond/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  
  <script>
  $(function() {
    $( "#tabs" ).tabs({
      collapsible: true
    });
  });
  </script>
  
   <link rel="stylesheet" href="css/bootstrap.css">
   <style>
        body {
 
              background-color: #eee;
      }
    
    

</style>
    </head>
    <body>
        <?php
        // put your code here
            require_once 'conecta.php';
            include "verifica.php"; 
            include "gerarCodigo.php";


        //vericando usuario
            if($_SESSION["auti"] == 1){
                
                 header("location:bolao.php");


            } 
            //verifica a página atual caso seja informada na URL, senão atribui como 1ª página
        $pagina = (isset($_GET['pagina']))? $_GET['pagina'] : 1;
                
                  $sqlJogo="SELECT * FROM tb_jogos";
                
                  $resul = mysql_query($sqlJogo);
                  $resul2= mysql_query($sqlJogo); 


                 function paginaAtual($i){
                     $pagina = $_GET['pagina'];
                     
                     if($pagina == $i){

                         return "active";
                     }
                   }
        ?>
        
                      <div id="tabs">
                                <ul>                                                          
                                       <li><a href="#tabs-2">Gerador De Senhas</a></li>
                                       <li><a href="#tabs-3">Cadastro de Jogos</a></li>
                                       <li><a href="#tabs-4">Cadastro de Resultados</a></li>
                             </ul>
                                                          
                                                          
                             <div id="tabs-2">                                                              
                                 <div class="row"> 

                                     <form role="form" method="post" action="<?php $s = geraSenha(3);?>">
                                     
                                     	<div class="col-xs-6 col-md-6">
					     <div class="form-group">
						<div class="col-xs-6 col-md-6"><input type="submit" value="Gerar Senha" class="btn btn-primary btn-block btn-lg" tabindex="8" name="enviar">
					</div>
				      </div>
				<div class="col-xs-6  col-md-6" id="erro">
					<div class="form-group">
                                                   <?php if(isset($_POST["enviar"])){ ?>
						      <strong> <span class="label label-danger"><?php echo $s; ?></span></strong>
                                                      <?php
                                                            $sqlCodigo = "INSERT INTO tb_codigo (idCod,codigo_cadastro) values('','$s')";
                                              $resul  = mysql_query($sqlCodigo);
                                              if($resul){
                                                  
                                                  echo "<strong><span class='label label-success'>Codigo Gerado</span></strong>";
                                            
                                              }
                                              ?>
                                                      
                                                      
                                                   <?php } ?>  
					</div>
				</div>
                                     
                                 
                                     
                                     </form>                              
                                                               
                                  </div>
                             </div>
                             </div>        
                            <div id="tabs-3">
                               <div class="panel panel-default">
                                           <div class="panel-body">
                                                 <div class="row">
                                                     <div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3">
                                                            <form role="form" method="post" action="cadJogo.php">
                    
			                                                          <h2>Cadastre os Jogos</h2>
                                                                    			<hr class="colorgraph">
                                                                    			<div class="row">
                                                                    				<div class="col-xs-6 col-sm-6 col-md-6">
                                                                    					<div class="form-group">
                                                                                            <input type="text" name="equipe1" id="first_name" class="form-control input-lg" placeholder="Equipe 1" tabindex="1">
                                                                    					</div>
                                                                    				</div>
                                                                    				<div class="col-xs-6 col-sm-6 col-md-6">
                                                                    					<div class="form-group">
                                                                    						<input type="text" name="equipe2" id="last_name" class="form-control input-lg" placeholder="Equipe 2" tabindex="2">
                                                                    					</div>
                                                                    				</div>
                                                                    			</div>	

                                                                    			<div class="row">
                                                                    				<div class="col-xs-6 col-sm-6 col-md-6">
                                                                    					<div class="form-group">
                                                                    				  <strong> Rodada </strong>
                                                                    					</div>
                                                                    				</div>
                                                                    				<div class="col-xs-6 col-sm-6 col-md-6">
                                                                    					<div class="form-group">
                                                                    					   <select name="rodada">
                                                                                    <option value="1 Rodada">1° Rodada</option>
                                                                                    <option value="2 Rodada">2° Rodada</option>
                                                                                    <option value="3 Rodada">3° Rodada</option>
                                                                                    <option value="Oitavas">Oitavas</option>
                                                                                    <option value="Quartas">Quartas</option>
                                                                                    <option value="Semi">Semi</option>
                                                                                    <option value="Final">Final</option>
                                                                               </select>
                                                                    					</div>
                                                                    				</div>                                                                                               
                                                                                                
                                                                    			</div>

			                                                             <hr class="colorgraph" id="h">
                                                              			<div class="row">
                                                              				<div class="col-xs-6 col-md-6"><input type="submit" value="Salvar" class="btn btn-primary btn-block btn-lg" tabindex="8" name="envia"></div>
                                                              			
                                                              			</div>
                                                   
	                                                        	</form>
        
                                                      </div>
                                                 </div>                                                
                                          </div>
                                   </div> 
                            </div>  

                              <div id="tabs-4">
                               <div class="panel panel-default">
                                           <div class="panel-body">
                                                 <div class="row">
                                                     <div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3">
                                                            <form role="form" method="post" action="cadResultado.php">
                                                             <?php ?>
                                                                <h2>Cadastre os Resultados</h2>
                                                                          <hr class="colorgraph">
                                                                           <div class="row">
                                                                            <div class="col-xs-6 col-sm-6 col-md-6">
                                                                              <div class="form-group">
                                                                               &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <strong> Jogo </strong>
                                                                              </div>
                                                                            </div>
                                                                            <div class="col-xs-6 col-sm-6 col-md-6">
                                                                              <div class="form-group">

                                                                                 <select name="jogo" class="form-control">
                                                                                  <?php while($registro2 = mysql_fetch_row($resul2)){ ?>

                                                                                     <option value="<?php echo $registro2[0]; ?>"><?php echo $registro2[0]." - ".$registro2[1]." X ".$registro2[2]; ?></option>

                                                                                  <?php } ?>
                                                                            
                                                                               </select>
                                                                              </div>
                                                                            </div>                                                                                               
                                                                                                
                                                                          </div>


                                                                          <div class="row">
                                                                            <div class="col-xs-6 col-sm-6 col-md-6">
                                                                              <div class="form-group">
                                                                                            <input type="text" name="resulTime1" id="first_name" class="form-control input-lg" placeholder="Resultado time 1" tabindex="1">
                                                                              </div>
                                                                            </div>
                                                                            <div class="col-xs-6 col-sm-6 col-md-6">
                                                                              <div class="form-group">
                                                                                <input type="text" name="resulTime2" id="last_name" class="form-control input-lg" placeholder="Resultado time 2" tabindex="2">
                                                                              </div>
                                                                            </div>
                                                                          </div>  

                                                                         

                                                                   <hr class="colorgraph" id="h">
                                                                    <div class="row">
                                                                      <div class="col-xs-6 col-md-6"><input type="submit" value="Salvar" class="btn btn-primary btn-block btn-lg" tabindex="8" name="envia"></div>
                                                                    
                                                                    </div>
                                                   
                                                            </form>
        
                                                      </div>
                                                 </div>                                                
                                          </div>
                                   </div> 
                            </div>                        
                </div> 

                <div class="panel panel-primary">

                  <?php 
                     

                      //configurando a paginaçao


    //seleciona todos os itens da tabela
        $cmd = "SELECT * FROM tb_jogos";
        $jogos = mysql_query($cmd);
   
    //conta o total de itens
        $total = mysql_num_rows($jogos);
   
    //seta a quantidade de itens por página, neste caso, 2 itens
        $registros = 4;
   
    //calcula o número de páginas arredondando o resultado para cima
        $numPaginas = ceil($total/$registros);
   
    //variavel para calcular o início da visualização com base na página atual
        $inicio = ($registros*$pagina)-$registros;
 
    //seleciona os itens por página
        $cmd = "SELECT * FROM tb_jogos limit $inicio, $registros";
        $jogos = mysql_query($cmd);
        $total = mysql_num_rows($jogos);

                 

                   

                    ?>
                     <div class="panel-heading">Tabela de Jogos</div>
                            <div class="panel-body">
                                  <div class="bs-example">      
                                        <table class="table">
                                            <thead>
                                              <tr>
                                                <th>#</th>
                                                <th>Time 1</th>
                                                <th>Resultado 1</th>
                                                <th>Time 2</th>      
                                                <th>Resultado 2</th>     
                                                <th>Rodada</th>                         
                                             </tr>
                                            </thead>
                                             <tbody>
                                              <?php while($registro = mysql_fetch_row($jogos)) {?>

                                             <tr class="">                                           
                                            <td><?php echo $registro[0];?></td> <!-- id -->
                                            <td><?php echo $registro[1]; ?></td> <!-- equipe1 -->
                                            <td><?php echo $registro[3]; ?></td> <!-- equipe -->
                                            <td> <?php echo $registro[2]; ?></td> <!-- email -->                                            
                                            <td> <?php echo $registro[4]; ?></td> <!-- email -->
                                            <td> <?php echo $registro[5]; ?></td> <!-- email -->        
                                             </tr>
                                                              <?php }?>
                                         
                                           </tbody>
                                        </table>
                                      

                                             <?php for($i = 1; $i < $numPaginas + 1; $i++) { ?>
                                                  <ul class='pagination' id='pagination'>

                                                    <li class="<?php echo paginaAtual($i);?>"> <a href='controle.php?pagina=<?php echo $i ?>'><?php echo $i; ?></a></li>

                                                  </ul>
                                             <?php }?>
                                 </div><!-- /example -->
                                              
                         </div>
                </div>
                               
                          <hr>   
                          <div class="panel-body">
   
                                <!-- ... aqui vai o <dl> que já temos hoje ... -->
                               <ul class="nav nav-pills">
                                   &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp  <strong style="font-size: 30px;">Usuario</strong> :  <a style="font-size:28px;"><?php echo $_SESSION["nome"]?> </a>
                                 <li class="active"><a href="logout.php">Sair</a></li>  

                            </ul>

                        </div>
              
    </body>
</html>
